# -*- coding=utf-8 -*-
import re
from Record import RecordIP
record_file = 'record_ip.txt'
recorder = RecordIP( record_file )
recorder.init()

uri_record = re.compile(u'/record(/[^/?\']+)*$')

test_uri = ['/record/ip',
            '/record',
            '/record/gps',
            '/record/gps/home',
            '/record/gps/home?name=xxx',
            '/info',
            ]

for uri in test_uri :
    m = uri_record.match(uri)
    # print m, m.groups()
    if m is not None :
        # print type(m), dir(m)
        flag = m.group(1)
        if flag != None and len(flag) > 1:
            flag = flag[1:]
            print flag
            print '==> ', m.groups(), m.string
            recorder.record( flag, 'xxx' )
recorder.export()

print ['{0}={1}\n'.format(k, recorder.cache[k])
            for k in sorted(recorder.cache)]

